﻿//进行删除操作时候选择资料的方法
function GetDelCheck(checkName, HiddenID) {
    var strMsg = "";
    var intMsg = 0;
    var strID = $("input[name=" + checkName + "]").each(function(index, domEle) {

        var sss = $(domEle);
        if (sss.attr("checked")) {
            var strMsg1 = $.trim(sss.val());
            if (strMsg1 != "") {
                intMsg++;
                strMsg += strMsg1 + ",";
            }
        }
    });

    if (strMsg == "") {
        alert("请先选择需要操作的资料");
        return false;
    } else {
        if (confirm("您确定要操作当前选择的" + intMsg + "条记录吗?")) {
            $("#" + HiddenID).val(strMsg);
            return true;
        } else {
            return false;
        }
    }
}
//进行操作时候选择资料的默认方法
function GetDelCheckDefault() {
    return GetDelCheck("DataCheck", "HiddenID");
}

function GetAllCheck(checkName, HiddenID) {
    var strMsg = "";
    var intMsg = 0;
    var strID = $("input[name=" + checkName + "]").each(function(index, domEle) {

        var sss = $(domEle);
        if (sss.attr("checked")) {
            //alert(sss.val());
            var strMsg1 = $.trim(sss.val());
            if (strMsg1 != "") {
                intMsg++;
                strMsg += strMsg1 + ",";
            }
        }
    });

    if (strMsg == "") {
        alert("请先选择需要操作的资料");
        return false;
    } else {
        if (confirm("您确定要操作当前选择的" + intMsg + "条记录吗?")) {
            $("#" + HiddenID).val(strMsg);
            return true;
        } else {
            return false;
        }
    }
}
//进行操作时候选择资料的默认方法
function GetAllCheckDefault() {
    return GetAllCheck("DataCheck", "HiddenID");
}

//进行修改操作时候选择资料的方法
function GetUpdateCheck(checkName, HiddenID) {
    var strMsg = "";
    var intMsg = 0;
    var strID = $("input[name=" + checkName + "]").each(function(index, domEle) {
        var sss = $(domEle);
        if (sss.attr("checked")) {
            //alert(sss.val());
            var strMsg1 = $.trim(sss.val());
            if (strMsg1 != "") {
                intMsg++;
                if (intMsg == 1) {
                    strMsg += strMsg1;
                }
            }
        }
    });

    if (strMsg == "") {
        alert("请先选择需要操作的资料");
        return false;
    } else {
        var strTemp = "";
        if (intMsg > 1) {
            strTemp = "您选择了多条资料,系统默认修改您选择的第一条资料\n";
            if (confirm(strTemp + "您确定要操作当前选择的这一条记录吗?")) {
                $("#" + HiddenID).val(strMsg);
                return true;
            } else {
                return false;
            }
        } else {
            $("#" + HiddenID).val(strMsg);
            return true;
        }

    }
}

//重置密码重置
function GetResertCheckDefault() {
    return GetDelCheck("DataCheck", "HiddenID");
}

//审核会员信息
function GetCheckUserInfoDefault() {
    return GetCheckUser("DataCheck", "HiddenID");
}

//进行修改操作时候选择资料的方法
function GetCheckUser(checkName, HiddenID) {
    var strMsg = "";
    var intMsg = 0;
    var strID = $("input[name=" + checkName + "]").each(function(index, domEle) {
        var sss = $(domEle);
        if (sss.attr("checked")) {
            var strMsg1 = $.trim(sss.val());
            if (strMsg1 != "") {
                intMsg++;
                if (intMsg == 1) {
                    strMsg += strMsg1;
                }
            }
        }
    });
    if (strMsg == "") {
        alert("请先选择需要审核的用户信息");
        return false;
    } else {
        var strTemp = "";
        if (intMsg > 1) {
            strTemp = "您选择了多条用户资料,系统默认修改您选择的第一条资料\n";
            if (confirm(strTemp + "您确定要审核当前用户信息吗?")) {
                if (document.getElementById("span" + strMsg).title == "已审核") {
                    alert("该用户已审核过了，请选择其他用户！");
                    return false;
                }
                else {
                    $("#" + HiddenID).val(strMsg);
                    return true;
                }
            } else {
                return false;
            }
        } else {
            if (confirm(strTemp + "您确定要审核当前用户信息吗?")) {
                if (document.getElementById("span" + strMsg).title == "已审核") {
                    alert("该用户已审核过了，请选择其他用户！");
                    return false;
                }
                else {
                    $("#" + HiddenID).val(strMsg);
                    return true;
                }
            } else {
                return false;
            }
        }
    }
}

//进行操作时候选择资料的默认方法
function GetUpdateCheckDefault() {
    return GetUpdateCheck("DataCheck", "HiddenID");
}
function CheckAll(cb, checkName) {
    $("input[name=" + checkName + "]").attr("checked", $(cb).attr("checked"));
}
function CheckAllDefault(cb) {
    return CheckAll(cb, "DataCheck");
}



//进行试卷题型组题操作时候选择资料的方法
function GetSelQuestionCheck(checkName, HiddenID) {
    var strMsg = "";
    var intMsg = 0;
    var strID = $("input[name=" + checkName + "]").each(function(index, domEle) {

        var sss = $(domEle);
        if (sss.attr("checked")) {
            //alert(sss.val());
            var strMsg1 = $.trim(sss.val());
            if (strMsg1 != "") {
                intMsg++;
                strMsg += strMsg1 + ",";
            }
        }
    });
    if (strMsg == "") {
        alert("请先选择需要加入的对应题型的题目");
        return false;
    } else {
        if (confirm("您确定选择当前的" + intMsg + "条记录吗?")) {
            $("#" + HiddenID).val(strMsg);
            return true;
        } else {
            return false;
        }
    }
}
//进行操作时候选择资料的默认方法
function GetSelQuestionCheckDefault() {
    return GetSelQuestionCheck("DataCheck", "SelectID");
}

function ShowPaperModalDialog() {
    var vMsg = "";
    var vSelCount = 0;
    var vID = $("input[name=DataCheck]").each(function(index, domE) {
        var vThis = $(domE);
        if (vThis.attr("checked")) {
            if ($.trim(vThis.val()) != "") {
                vSelCount++;
                vMsg += $.trim(vThis.val()) + ",";
            }
        }
    });
    if (vSelCount <= 0) {
        alert("请先选择需要预览的试卷");
        return false;
    }
    else if (vSelCount > 1) {
        alert("一次只允许预览一份试卷");
        return false;
    }
    else {
        var obj = new Object();
        var vSelectedID = vMsg.substr(0, vMsg.length - 1); //去掉最后个 ","
        var selectId = window.showModalDialog("ExamPreView.aspx?ExamPaperID=" + vSelectedID, obj, "dialogWidth=800px;dialogHeight=600px");
        return false;
    }
}


var Request = {
    QueryString: function(item) {
        var svalue = location.search.match(new 
RegExp('[\?\&]' + item + '=([^\&]*)(\&?)', 'i'));
        return svalue ? svalue[1] : svalue;
    }
}

//获得ｕｒｌ的参数




/*
设置上传文件的脚本
strRoot:绝对的根路径,会自动形成 strRoot+"/root" root是根下的一个子目录
sessionid,请传入<=Session.SessionID %>
divFileProgressContainer,预览图片防止的divid
*/
//function SWFUpImage(strRoot, SessionID, spanButtonPlaceholder, divFileProgressContainer) {
//    var swfuzj;
//    swfuzj = new SWFUpload({
//        upload_url: strRoot + "/swfupload/webupload.aspx", //上传处理的路径
//        post_params: {
//            "ASPSESSID": SessionID
//        },
//        file_size_limit: "2 MB", //文件大小
//        file_types: "*.jpg;*.png;*.gif", //文件类型使用分号隔开
//        file_types_description: "图片文件", //文件选择对话框的显示
//        file_upload_limit: "2",    // 文件上传数量

//        // Event Handler Settings - these functions as defined in Handlers.js
//        //  The handlers are not part of SWFUpload but are part of my website and control how
//        //  my website reacts to the SWFUpload events.
//        file_queue_error_handler: fileQueueError,
//        file_dialog_complete_handler: fileDialogComplete,
//        upload_progress_handler: uploadProgress,
//        upload_error_handler: uploadError,
//        upload_success_handler: uploadSuccess,
//        upload_complete_handler: uploadComplete,

//        // Button settings
//        button_image_url: "",
//        button_placeholder_id: spanButtonPlaceholder,
//        button_width: 100,
//        button_height: 22,
//        button_text: '<span style="cursor:pointer" >选择图片<span class="buttonSmall">(2M)</span></span>',
//        button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
//        button_text_top_padding: 1,
//        button_text_left_padding: 5,

//        // Flash Settings
//        flash_url: strRoot + "/swfupload/swfupload.swf", // 上传flash文件的路径

//        custom_settings: {
//            upload_target: divFileProgressContainer
//        },

//        // Debug Settings
//        debug: false
//    });
//    return swfuzj;
//}

//var HGWSwf = function(strRoot, SessionID, divID, sType) {
//    this.Root = strRoot;
//    this.SessionID = SessionID;
//    this.stype = sType || 0;
//    if (this.stype == 0) {
//        this.buttonID = "Swf_ButID";
//        this.ProgID = "thumbnails";
//    } else {
//        this.buttonID = "Swf_ButID1";
//        this.ProgID = "thumbnails1";
//    }
//    this.swf;
//    this.divID = divID;
//    $("#" + this.divID).html('<span id="' + this.buttonID + '"></span><span id="' + this.ProgID + '"></span>');

//};
//HGWSwf.prototype.Init = function(divid) {
//    alert(divid);
//}
//HGWSwf.prototype.NewSwf = function() {
//    this.swf = new SWFUpload({
//        upload_url: this.Root + "/swfupload/webupload.aspx", //上传处理的路径
//        post_params: {
//            "ASPSESSID": this.SessionID
//        },
//        file_size_limit: "2 MB", //文件大小
//        file_types: "*.jpg;*.png;*.gif", //文件类型使用分号隔开
//        file_types_description: "图片文件", //文件选择对话框的显示
//        file_upload_limit: "1",    // 文件上传数量

//        // Event Handler Settings - these functions as defined in Handlers.js
//        //  The handlers are not part of SWFUpload but are part of my website and control how
//        //  my website reacts to the SWFUpload events.
//        file_queue_error_handler: this.fileQueueErr,
//        file_dialog_complete_handler: fileDialogComplete,
//        upload_progress_handler: uploadProgress,
//        upload_error_handler: uploadError,
//        upload_success_handler: uploadSuccess,
//        upload_complete_handler: this.UpFile,

//        // Button settings
//        button_image_url: "",
//        button_placeholder_id: this.buttonID,
//        button_width: 100,
//        button_height: 22,
//        button_text: '<span style="cursor:pointer" >选择图片<span class="buttonSmall">(2M)</span></span>',
//        button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
//        button_text_top_padding: 1,
//        button_text_left_padding: 5,

//        // Flash Settings
//        flash_url: this.Root + "/swfupload/swfupload.swf", // 上传flash文件的路径

//        custom_settings: {
//            upload_target: this.ProgID
//        },
//        // Debug Settings
//        debug: false
//    });
//}
//HGWSwf.prototype.NewSwf1 = function() {
//    this.swf = new SWFUpload({
//        upload_url: this.Root + "/swfupload/webupload1.aspx", //上传处理的路径
//        post_params: {
//            "ASPSESSID": this.SessionID
//        },
//        file_size_limit: "2 MB", //文件大小
//        file_types: "*.jpg;*.png;*.gif", //文件类型使用分号隔开
//        file_types_description: "图片文件", //文件选择对话框的显示
//        file_upload_limit: "1",    // 文件上传数量

//        // Event Handler Settings - these functions as defined in Handlers.js
//        //  The handlers are not part of SWFUpload but are part of my website and control how
//        //  my website reacts to the SWFUpload events.
//        file_queue_error_handler: this.fileQueueErr,
//        file_dialog_complete_handler: fileDialogComplete,
//        upload_progress_handler: uploadProgress,
//        upload_error_handler: uploadError,
//        upload_success_handler: uploadSuccess1,
//        upload_complete_handler: this.UpFile,

//        // Button settings
//        button_image_url: "",
//        button_placeholder_id: this.buttonID,
//        button_width: 100,
//        button_height: 22,
//        button_text: '<span style="cursor:pointer" >选择图片<span class="buttonSmall">(2M)</span></span>',
//        button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
//        button_text_top_padding: 1,
//        button_text_left_padding: 5,

//        // Flash Settings
//        flash_url: this.Root + "/swfupload/swfupload.swf", // 上传flash文件的路径

//        custom_settings: {
//            upload_target: this.ProgID
//        },
//        // Debug Settings
//        debug: false
//    });
//}
//HGWSwf.prototype.RefSwf = function() {
//    this.swf.destroy();
//    $("#" + this.divID).html('<span id="' + this.buttonID + '"></span><span id="' + this.ProgID + '"></span>');
//    this.NewSwf();
//}
//HGWSwf.prototype.UpFile = function(file) {
//    try {
//        if (this.getStats().files_queued > 0) {
//            this.startUpload();
//        } else {
//            var progress = new FileProgress(file, this.customSettings.upload_target);
//            progress.setComplete();
//            progress.setStatus("操作完成.");
//            progress.toggleCancel(false);
//        }
//    } catch (ex) {
//        this.debug(ex);
//    }
//}

//HGWSwf.prototype.fileQueueErr = function(file, errorCode, message) {
//    try {
//        var imageName = "error.gif";
//        var errorName = "";
//        if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) {
//            errorName = "文件上传数量太多.";
//        }

//        if (errorName !== "") {
//            alert(errorName);
//            return;
//        }

//        switch (errorCode) {
//            case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
//                imageName = "zerobyte.gif";
//                break;
//            case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
//                imageName = "toobig.gif";
//                break;
//            case -100:

//                if (message = "0") {
//                    message = "您选择的文件太多,或者您已经选择过文件,不可以再选择了";
//                } else {
//                    message = "您现在只能上传" + message + "个文件";
//                }
//                alert(message);
//                break;
//            case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
//            case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
//            default:
//                alert(message);
//                break;
//        }

//        addImage("images/" + imageName);

//    } catch (ex) {
//        this.debug(ex);
//    }

//}

////$(document).ready(function() {
////    var examLink = $("a.exam_link");
////    examLink.click(function() {
////        var me = $(this);
////        var obj = new Object();
////        me.parent("li").prev("li").children("input[type='checkbox']").attr("checked", "checked").parents("dd").siblings().find("input[type='checkbox']").attr("checked", "");
////        window.showModalDialog("ExamPreView.aspx?ExamPaperID=" + me.attr("id"), obj, "dialogWidth=800px;dialogHeight=600px");
////    });
////    //
////    var dlItemOldColor;
////    $("dl.mul_table dd").hover(function() {
////        dlItemOldColor = $(this).css("backgroundColor");
////        $(this).css("background", "#FEFFB3");
////    }, function() {
////        $(this).css("background", dlItemOldColor);
////    });
////    //
////    $("#dataform").css("height", (window.top.document.documentElement.clientHeight - 126) + "px");
////    $(window).resize(function() {
////         $("#dataform").css("height", (window.top.document.documentElement.clientHeight - 126) + "px");
////    });
////});
